<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>首页</title>
	<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
	<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
	<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
	<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>	
    
    <!-- <link rel="stylesheet" href="./assets/css/bootstrap.min.css">
    <script src="./assets/js/jquery.min.js"></script>
    <script src="./assets/js/bootstrap.min.js"></script> -->
</head>
<body >
<?php  
		require_once('head.php');
		require_once ".\system\dbConn.php";
		$sql1="select * from demand where ischeck=0 limit 4";
		$result1=mysqli_query($link,$sql1);
		$sql2="select * from goods where ischeck=0 limit 6";
		$result2=mysqli_query($link,$sql2);
		$sql3="select * from activity limit 2";
		$result3=mysqli_query($link,$sql3);

?>

<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img class="d-block w-100" src="./assets/indx2.jpg" alt="First slide" style="height: 500px">
    </div>
  </div>
</div>
   
<div class="">
            <div class="">
                <div class="">
                    <h4 style="margin-left: 100px;margin-top: 60px">学生来帮忙</h4>
                    <hr style="border-top:5px ridge #C0C0C0;margin-left: 99px" width="7%" />
                    <ul class="" style="margin-left: 100px;margin-right: 100px">
						<div class="row" >
						    		<table class="table table-hover" >	
						    		
									<thead class="thead-dark">
										<th>序号</th>
										<th>任务名称</th>
										<th>任务详情</th>
										<th>任务类型</th>
										<th>时限</th>
										<th>报酬</th>
										<th>发布时间</th>
										<th>发布人</th>
										<th>操作</th>
									</thead>

								<?php
								$i=0;
								while ($row1=mysqli_fetch_assoc($result1)) {	
									$i++;
								?>
									<tr>
										<td><?php echo $i; ?></td>
										<td><?php echo $row1["name"]; ?></td>
										<td><?php echo $row1["details"]; ?></td>
										<td><?php 
											if ($row1["type"] == 0) {
											 	echo "寻找失物";
											 } elseif ($row1["type"] == 1) {
											 	echo "物品借用";
											 }elseif ($row1["type"] == 2) {
											 	echo "疑惑解答";
											 }elseif ($row1["type"] == 3) {
											 	echo "电脑修理";
											 }
										?></td>
										<td><?php 
											if ($row1["time"] == 0) {
										 	echo "5min之内";
										 } elseif ($row1["time"] == 1) {
										 	echo "5~15min";
										 }elseif ($row1["time"] == 2) {
										 	echo "15~30min";
										 }elseif ($row1["time"] == 3) {
										 	echo "一天以内";
										 }elseif ($row1["time"] == 4) {
										 	echo "一周以内";
										 }
										 ?></td>
										<td><?php echo $row1["money"]."元"; ?></td>
										<td><?php echo $row1["uploaddate"]; ?></td>
										<td><?php echo $row1["uploadusers"]; ?></td>
										<td>
										<?php 
												if(isset($_SESSION["username"])){
												$uploadusers=$_SESSION["username"];
										?>
										<?php  
											if ($row1["isaccept"]==1) {
										?>
													<h6>已接受</h6>
										<?php }else{ ?>
												<a href="accept.php?id=<?php echo $row1["id"]; ?>&aname=<?php echo $row1["name"]; ?>">接受任务</a>
										<?php } ?>	
										<?php
										}
										else{
										?>
												<h6 class="intro-text text-center"><a a href="#" data-toggle="modal" data-target="#login1"">登录</a>后接受任务</h6>
										<?php
										}
										?>		

										</td>
									</tr>
								<?php
								}
							?>

							
								</table>
								</div>

                    </ul>
                    <p style="float: right;"><a class="btn btn-default" href="list.php" role="button" style="font-size: 20px">更多 &raquo;</a></p>
                </div>
                <!--/.col-xs-6.col-lg-4-->

            </div>
            <!--/row-->


            <div class="" >
                <div class="" >
                    <h4 style="margin-left: 100px;margin-top: 60px">二手商品</h4>
                    <hr style="border-top:5px ridge #C0C0C0;margin-left: 99px" width="5%" />
                    <ul class="list-inline row text-center" style="margin-left: 100px;margin-right: 100px">


                    <?php 
                    while ($row2=mysqli_fetch_assoc($result2)) {
                       ?>
                         <div class="row" style="margin-left: 30px;background-color:#ffffff;padding:10px;margin-top: 20px">
										  <div class="col-sm-2 col-md-12">
										    <div class="thumbnail">
										       <img src="./images/<?php echo $row2["pic"];?>" class="img-responsive" alt="Responsive image"  width="140" height="180" title="介绍：<?php echo $row2["detial"]; ?>">

										      <div class="caption" style="margin-top: 10px">
										        <h6><a href="#"><?php echo $row2["gname"]; ?></a></h6>
										        <p style="font-size: 10px"><?php echo $row2["time"]; ?>&nbsp&nbsp<?php echo "￥".$row2["price"]."元 "; ?></p>
										        <p style="font-size: 13px"><?php echo $row2["uploaduser"]; ?>:&nbsp&nbsp<?php echo $row2["phone"]; ?></p>
										      </div>
										    </div>
										  </div>
										</div>
                       <?php 
                    }
                     ?>

                    </ul>
                    <p style="float: right;"><a class="btn btn-default" href="market.php" role="button" style="font-size: 20px">更多 &raquo;</a></p>
                </div>

            </div>

	 		<div class="" id="sidebar">
	         <div class="">
	                <h4 style="margin-left: 100px;margin-top: 60px">活动</h4>
	                <hr style="border-top:5px ridge #C0C0C0;margin-left: 99px" width="3%" />
	 	<div style="width: 75%;margin:20px auto;">
	<?php
		$index=0;
		while ($row3=mysqli_fetch_assoc($result3)) {	
		?>
		<div class="card-hidden" id="card-hidden-<?php echo $index;?>" style="margin-top:70px;margin-bottom:10px;background: #ffffff;border-radius:20px;box-shadow:10px 10px 5px #C7C7C7;border-radius:20px;">
		 <div class="col-md-12 col-sm-12">
	    	<div class="panel panel-default" >
	    		<br>
			  <div class="panel-heading" align="center" style="margin-top: 15px"><h4><?php echo $row3["aname"]; ?></h4></div>
			  <div class="panel-body" >
			    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<?php echo $row3["adetial"]; ?>
			  </div>
			  <br>
			  <div style="float: right;"><button type="button" class="btn-more" id="btn-more-<?php echo $index;?>">显示更多</button></div>
			   <br>
			  <div class="panel-footer" align="center"><?php 
							if(isset($_SESSION["username"])){
							$uploadusers=$_SESSION["username"];
					?>
							<a href="doActivity.php?aname=<?php echo $row3["aname"] ?>">报名参加</a>
					<?php
					}
					else{
					?>
							<h6 class="intro-text text-center"><a a href="#" data-toggle="modal" data-target="#login1"">登录</a>后报名参加</h6>
					<?php
					}
					?></div>
			  <br>
			</div>
		 </div>
		</div>

		<div class="card-shown" id="card-shown-<?php echo $index;?>" style="margin-top:70px;margin-bottom:10px;background: #ffffff;border-radius:20px;box-shadow:10px 10px 5px #C7C7C7;border-radius:20px;">
		 <div class="col-md-12 col-sm-12">
	    	<div class="panel panel-default" >
	    		<br>
			  <div class="panel-heading" align="center"  style="margin-top: 15px"><h4><?php echo $row3["aname"]; ?></h4></div>
			  <div class="panel-body1" >
			    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<?php echo $row3["adetial"]; ?>
			  </div>
			   <br>
			  <div class="panel-footer" align="center">
					<?php 
							if(isset($_SESSION["username"])){
							$uploadusers=$_SESSION["username"];
					?>
							<a href="doActivity.php?aname=<?php echo $row3["aname"] ?>">报名参加</a>
					<?php
					}
					else{
					?>
							<h6 class="intro-text text-center"><a a href="#" data-toggle="modal" data-target="#login1">登录</a>后报名参加</h6>
					<?php
					}
					?>		
			  </div>
			  <br>
			</div>
		 </div>
		</div>

		<?php
		$index=$index+1;
		}
		
		?>
	                    <p style="float: right;"><a class="btn btn-default" href="activity.php" role="button" style="font-size: 20px">更多 &raquo;</a></p>
	            </div>
	            </div>


        </div>
        </div>
        <!--/.sidebar-offcanvas-->

</div>
<!--/.container-->

<div class="modal fade" id="login1" tabindex="-1" role="dialog" aria-labelledby="login1" aria-hidden="true">
	<div class="modal-dialog modal-dialog-centered" role="document">
	  <div class="modal-content">
	    <div class="modal-header">
				<h5 class="modal-title" id="login">登录</h5>
	      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>		        
	    </div>
	    <div class="modal-body">
			<form class="form-horizontal" id="loginForm" action="doUserLog.php" method="post">
			  <div class="form-group">
			    <!-- <label for="inputUsername" class="col-md-4 control-label">用户名：</label> -->
			    <div class="col-md-12">
			      <input type="text" class="form-control" id="inputUsername" name="username" placeholder="用户名">
			    </div>
			  </div>
			  <div class="form-group">
			    <!-- <label for="inputPassword3" class="col-md-4 control-label">密码：</label> -->
			    <div class="col-md-12">
			      <input type="password" class="form-control" id="inputPassword3" name="password" placeholder="密码">
			    </div>
			  </div>
			  <div class="form-group">
			    <div class="col-sm-offset-2 col-sm-10">
			      <button id="loginBtn" type="submit" class="btn btn-default">登录</button>
			    </div>
			  </div>
			</form>
	    </div>
	  </div>
	</div>
</div>  
</body>
<style >
	 body{
	 	 background: #f2f2f2;

	 }
  .panel-body{
        display: -webkit-box;
        overflow: hidden;
        white-space: normal !important;
        text-overflow: ellipsis;
        word-wrap: break-word;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
    }
    table { table-layout:fixed; word-break: break-all; word-wrap: break-word; }  
</style>
<script>
$(document).ready(function(e) {
		$(".card-hidden").show().addClass("show");
             // 执行隐藏
    $(".card-shown").hide().removeClass("show");
    $("button[id^='btn-more-']").click(function(e) {
				const index = e.target.id.replace("btn-more-","");
        if( $("#card-hidden-"+index).hasClass("show") ){
            // 执行隐藏
            $("#card-hidden-"+index).hide().removeClass("show");
            //显示
            $("#card-shown-"+index).show().addClass("show");
            // 其他
        }else{
            // 显示
            $("#card-hidden-"+index).show().addClass("show");
             // 执行隐藏
             $("#card-shown-"+index).hide().removeClass("show");
        }
    });
});

</script>
</html>